<?php defined('IN_ADMIN') or exit('No permission resources.');

if(!$file_upload_limit)$file_upload_limit = 5;
$filetype_post = 'jpg|jpeg|gif|bmp|png|doc|docx|xls|xlsx|ppt|pptx|pdf|txt|rar|zip|html|eml|htm|mht';
$file_types = '*.jpg;*.jpeg;*.gif;*.bmp;*.png;*.doc;*.docx;*.xls;*.xlsx;*.ppt;*.pptx;*.pdf;*.txt;*.rar;*.zip;*.html;*.eml;*.htm;*.mht';

$file_size_limit = sizecount(8048*1024);
$swf_auth_key = md5($_SESSION['pc_hash'].substr(md5(SYS_TIME),4,8));

?>
<link href="<?php echo JS_PATH?>swfupload/swfupload.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/swfupload.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/fileprogress.js"></script>
<script language="JavaScript" type="text/javascript" src="<?php echo JS_PATH?>swfupload/handlers.js"></script>
<script type="text/javascript">
function delAtt(id,obj)
{
	if(!confirm('确定删除？'))return false;
	if(id){
		$.post('?m=work&c=work&a=swfup&pc_hash='+pc_hash,{del:1,'id':id,'dosubmit':1});
	}
	$(obj).parent().remove();
	return false;
}
var iii=0;
function att_show(data,file)
{
	iii++;
	if(typeof file !='object')file = {name:'',id:'sys_error_'+iii};
	if(data.length<1){
		//alert('上传失败');
		$('#att_uploaded_list').append('<li id="atl_'+file.id+'">'+file.name+'上传失败,服务器出错，请重新上传</li>');
		setTimeout(function(){$('#atl_'+file.id).remove();},5000);
		return false;
	}
	var ret = eval('('+data+')');;
	if(ret.code){
		$('#att_uploaded_list').append('<li id="atl_'+file.id+'">'+file.name+'上传失败,'+ret.err+'，请重新上传</li>');
		//$('#att_uploaded_list').append('<li class="error">上传失败</li>');
		setTimeout(function(){$('#atl_'+file.id).remove();},5000);
		return false;
	}
	$('#att_uploaded_list').append('<li id="atl_'+file.id+'"><input type="hidden" name="att_ids[]" value="'+ret.attid+'" id="att_ids[]">'+file.name+'<a class="progressCancel" href="#" onclick="return delAtt('+ret.attid+',this)" style="visibility: visible;"> </a></li>');
	//<li>xxxxxx </li>   
	//console.log(data);
	//console.log(file);
	return false;
}

var swfu = '';
$(document).ready(function(){
swfu = new SWFUpload({
	flash_url:"<?php echo JS_PATH?>swfupload/swfupload.swf?"+Math.random(),
	upload_url:"?m=work&c=swfup&a=work&pc_hash="+pc_hash,
	file_post_name : "file",
	post_params:{"SWFUPLOADSESSID":"<?=$_COOKIE['PHPSESSID'];?>","dosubmit":"1","t":"<?=SYS_TIME;?>","swf_auth_key":"<?=$swf_auth_key;?>"},
	file_size_limit:"<?=$file_size_limit;?>",
	file_types:"<?=$file_types;?>",
	file_types_description:"All Files",
	file_upload_limit:"<?=$file_upload_limit;?>",
	custom_settings : {progressTarget : "fsUploadProgress",cancelButtonId : "btnCancel"},

	button_image_url: "",
	button_width: 75,
	button_height: 28,
	button_placeholder_id: "buttonPlaceHolder",
	button_text_style: "",
	button_text_top_padding: 3,
	button_text_left_padding: 12,
	button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
	button_cursor: SWFUpload.CURSOR.HAND,

	file_dialog_start_handler : fileDialogStart,
	file_queued_handler : fileQueued,
	file_queue_error_handler:fileQueueError,
	file_dialog_complete_handler:fileDialogComplete,
	upload_progress_handler:uploadProgress,
	upload_error_handler:uploadError,
	upload_success_handler:uploadSuccess,
	upload_complete_handler:uploadComplete
	});
});
</script>
<div id="div_swf_1" class="content pad-10">
<fieldset class="blue pad-10">
<legend>附件</legend>
    <ul class="attachment-list"  id="att_uploaded_list">
      <?php if(is_array($attr_list))foreach($attr_list as $att){?>
     <li><a href="caches/staff_atta/<?=$att['filepath'];?>" target="_blank"><?=$att['filename'];?></a> <a class="progressCancel" href="#" onclick="return delAtt(<?=$att['id'];?>,this)" style="visibility: visible;"> </a></li>
     <?php } ?>
    </ul>
    </fieldset>
<div class="bk10"></div>
    <div>
        <div class="addnew" id="addnew">
            <span id="buttonPlaceHolder"></span>
        </div>
        <input type="button" id="btupload" value="开始上传" onClick="swfu.startUpload();" />
        <div id="nameTip" class="onShow">最多上传<font color="red"> <?php echo $file_upload_limit?></font> 个附件,单文件最大 <font color="red"><?php echo $file_size_limit?></font>
          
        </div>
        <div class="bk3"></div>
        <div class="lh24">支持 <font style="font-family: Arial, Helvetica, sans-serif"><?php echo str_replace(array('*.',';'),array('','、'),$file_types)?></font> 格式。</div>
    </div> 	
    <div class="bk10"></div>
    <fieldset class="blue pad-10" id="swfupload">
    <legend>文件选择列表</legend>
    <ul class="attachment-list"  id="fsUploadProgress">    
    </ul>
    </fieldset>
</div>
        
        

